/*
 * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.inspur.edp.udt.generator.api;

import com.inspur.edp.caf.generator.BaseGenerator;
import com.inspur.edp.cef.generator.apiGenerator.CefApiGenerator;
import com.inspur.edp.cef.generator.apiGenerator.CefApiGeneratorContext;
import com.inspur.edp.cef.generator.apiGenerator.dataType.mgrAllInterface.MgrAllInterfaceGenerator;
import com.inspur.edp.cef.generator.apiGenerator.dataType.mgrInterface.MgrInterfaceGenerator;
import com.inspur.edp.cef.generator.apiGenerator.dataType.mgrInterface.mgrInfo.MgrInfoBaseGenerator;
import com.inspur.edp.cef.generator.apiGenerator.dataType.mgrInterface.resourceInfo.ModelInfoBaseGenerator;
import com.inspur.edp.cef.generator.apiGenerator.dataType.mgrInterface.valueObjMgrInfo.ValueObjMgrInfoGenerator;
import com.inspur.edp.udt.generator.UdtGeneratorContext;
import com.inspur.edp.udt.generator.api.entityallinterface.UdtEntityAllInterfaceGenerator;
import com.inspur.edp.udt.generator.api.entityinterface.UdtEntityInterfaceGenerator;
import com.inspur.edp.udt.generator.api.mgrallinterface.UdtMgrAllInterfaceGenerator;
import com.inspur.edp.udt.generator.api.mgrinterface.UdtMgrInterfaceGenerator;
import com.inspur.edp.udt.generator.api.mgrinterface.UdtModelInfoGenerator;
import com.inspur.edp.udt.generator.api.typeprocessers.persistencevaluereader.PersistenceValueReadersGenerator;

import java.util.ArrayList;

public class UdtApiGenerator extends CefApiGenerator
{
	private UdtGeneratorContext udtGenContext;
	public UdtApiGenerator(UdtGeneratorContext udtGenContext)
	{
		super(udtGenContext);
		this.udtGenContext = udtGenContext;
	}

//C# TO JAVA CONVERTER WARNING: There is no Java equivalent to C#'s shadowing via the 'new' keyword:
//ORIGINAL LINE: private new UdtApiGenCtx Context => (UdtApiGenCtx)super.Context;
	private UdtApiGenCtx getUdtApiGenContext(){return (UdtApiGenCtx)super.getContext();}

	@Override
	protected String getPackageName() {
		return udtGenContext.getUdt().getApiNamespace().getAssemblyName();
	}

	protected String getAssemblyName()
	{
		return udtGenContext.getUdt().getApiNamespace().getAssemblyName();
	}
	@Override
	protected void extendAfterGenerate()
	{
		super.extendAfterGenerate();
		//InitReaderTypes();
		//InitPersistenceValueReaderTypes();
		//new ProjectRefGenerator(udtGenContext).Generate();
	}

	//private void InitReaderTypes()
	//{
	//    foreach (var item in Context.DataReaderMediateTypes)
	//    {
	//        Context.UdtGenContext.ReaderTypes.Add(item.Key, Context.Assembly.GetType(item.Value.FullName));
	//    }
	//}

	//private void InitPersistenceValueReaderTypes()
	//{
	//    foreach (var item in Context.PersistenceValueReaderType)
	//    {
	//        Context.UdtGenContext.PersistenceValueReaderTypes.Add(item.Key, Context.Assembly.GetType(item.Value.FullName));
	//    }
	//}

	@Override
	protected CefApiGeneratorContext createCefApiGenContext()
	{
		return new UdtApiGenCtx(udtGenContext);
	}

	@Override
	protected java.util.ArrayList<BaseGenerator> getExtendChildGenerators()
	{
//C# TO JAVA CONVERTER TODO TASK: There is no equivalent to implicit typing in Java:
		ArrayList<BaseGenerator> list = super.getExtendChildGenerators();
		if (list == null)
		{
			list = new java.util.ArrayList<BaseGenerator>();
		}
		list.add(new UdtEntityInterfaceGenerator(getUdtApiGenContext()));
		list.add(new UdtEntityAllInterfaceGenerator(getUdtApiGenContext()));
		//list.Add(new DataReadersGenerator(Context));
		list.add(new PersistenceValueReadersGenerator(getUdtApiGenContext()));
		return list;
	}

	@Override
	protected MgrAllInterfaceGenerator getMgrAllInterfaceGenerator()
	{
		return new UdtMgrAllInterfaceGenerator(getUdtApiGenContext());
	}

	@Override
	protected MgrInterfaceGenerator getMgrInterfaceGenerator()
	{
		return new UdtMgrInterfaceGenerator(getUdtApiGenContext());
	}

	@Override
	protected MgrInfoBaseGenerator createMgrInfoGenerator()
	{
		return new ValueObjMgrInfoGenerator(getUdtApiGenContext(), getUdtApiGenContext().getUdtGenContext().getUdt());
	}

	@Override
	protected ModelInfoBaseGenerator createModelInfoGenerator() {
		return new UdtModelInfoGenerator(getUdtApiGenContext(),getUdtApiGenContext().getUdtGenContext().getUdt());
	}
}
